package com.lzw.dao;

import com.lzw.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
@Repository
//用户表的功能接口：（定义用户表的所有功能）
public interface UserDao {
    //登录功能
    @Results(id ="userMap",value={
            @Result(id=true,property = "uid",column = "u_id"),
            @Result(property = "uname",column = "u_name"),
            @Result(property = "upwd",column = "u_pwd"),
            @Result(property = "uimage",column = "u_image")
    })
    @Select("select * from user where u_name=#{uname} and u_pwd=#{upwd}")
    User login(@Param("uname") String uname, @Param("upwd") String upwd);
    @Insert("insert into User (u_name,u_pwd,u_image) values (#{uname},#{upwd},#{uimage})")
    int ZhuCe(User user);
    @ResultMap("userMap")
    @Select("select * from user")
    List<User> selectAll();
    @ResultMap("userMap")
    @Select("select u_name from user")
    List <User> selectAllUname();
    //验证账号是否存在
    @ResultMap("userMap")
    @Select("select u_id,u_image from user where u_name=#{uname}")
    User getUserByName(String uname);
    @Update("update user set u_pwd = #{upwd},u_image=#{uimage} where u_name = #{uname}")
    int updateUser(User user);
}
